package com.ruoyi.tenant.config;

import com.ruoyi.tenant.interceptor.DateSourceInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;




/**
 *
 * @author
 */
@Configuration
public class TenantConfig implements WebMvcConfigurer
{

    @Autowired
    private DateSourceInterceptor dateSourceInterceptor;

    /**
     * 自定义拦截规则
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(dateSourceInterceptor)
                .addPathPatterns("/**")
                //放行切换数据源拦截
                .excludePathPatterns("/captchaImage")
                .excludePathPatterns( "/*.html", "/**/*.html", "/**/*.css", "/**/*.js","/**/*.woff","/**/*.ttf",
                        "/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**",
                        "/profile/**","/initdatabase/creat","/error","/swagger-resources"
                );
    }

}
